class Solution
{
public:
    bool find_suffix(string s, string m)
    {
        if (s.find(m) == 0)
            return true;
        return false;
    }
    bool all_suffix(vector<string>& strs, string m)
    {
        for (int i = 0; i < strs.size(); ++i)
            if (find_suffix(strs[i], m) == false)
                return false;
        return true;
    }
    string longestCommonPrefix(vector<string>& strs)
    {
        string suffix = "";
        int i = 0;
        string tool = "";
        tool.push_back(strs[0][0]);
        if (!all_suffix(strs, tool))
            return "";
        do
        {
            suffix.push_back(strs[0][i]);
            ++i;
        }
        while (all_suffix(strs, suffix));
        suffix.pop_back();
        return suffix;
    }
};